<?php
defined('BASEPATH') OR exit('No direct script access allowed');

//分类
class Article_cat extends CommonController {
	function __construct(){
		parent::__construct();
		
		$this->load->mmodel('ArticleCatModel','CurModel','Article');
		
	}
	
	//start
	/**
	* @name 获取列表
	* @param page ture char 页面
	* @param size ture char 数量
	* @return 成功返回1
	*/
	//end
	function get_list(){
		$user_id = $this->user_id;
		
		$filter = array('name');
		$arr = array(
			'filter'=>$filter
		);
		
		$result = parent::_get_list($arr);
		if(!$result){
			$this->err_out($this->getError());
		}

		
		$this->data_out($result);
	}
	
	function info_out($info){
		
		
		return $info;
	}
	
	//start
	/**
	* @name 获取信息
	* @param id ture char ID
	* @return 成功返回1
	*/
	//end
	function get_info(){
		$user_id = $this->user_id;
		
		$result = parent::_get_info();
		if(!$result){
			$this->err_out($this->getError());
		}
		
		$this->data_out($result);
	}
	
	//start
	/**
	* @name 获取信息
	* @param id ture char ID
	* @return 成功返回1
	*/
	//end
	function save(){
		
		$filter = array(
			'name'=>'名称不能为空',
		);
		
		$post = array('name','info','img');
		$farr = array(
			'post'=>$post,
			'filter'=>$filter
		);

		$result = parent::_save($farr);
		if(!$result){
			$this->err_out($this->getError());
		}
		
		$this->add_log("保存文章分类【{$result['id']}】信息",'article_cat');
		
		$this->data_out($result);
	}
	


	
	//start
	/**
	* @name 删除
	* @param id ture int ID
	* @return 成功返回1
	*/
	//end
	function del(){
		
		$result = parent::_del();
		if(!$result){
			$this->err_out($this->getError());
		}
		
		
		$this->add_log("删除文章分类【{$result}】信息",'article_cat');
		$this->data_out($result);
		
	}
	
	//start
	/**
	* @name 获取子分类
	* @param parent_id ture int 父ID
	* @return 成功返回1
	*/
	//end
	function get_cat_list(){
		
		$parent_id = $this->input->post('parent_id',null,0);
		
		$list = $this->CurModel->getAll("parent_id='{$parent_id}'");
		$this->data_out($list);
		
	}
	
}

?>